home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / src / dl / dl_linkfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-14  |  2.2 KB  |  61 lines

  1. /***********************************************************
  2. Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  3. Netherlands.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Stichting Mathematisch
  12. Centrum or CWI not be used in advertising or publicity pertaining to
  13. distribution of the software without specific, written prior permission.
  14.  
  15. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  18. FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  21. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  
  23. ******************************************************************/
  24. /*
  25. ** dl_linkfile - Link a file.
  26. */
  27.  
  28. #include <sys/types.h>
  29.  
  30. extern int sprintf (char *, const char *, ...);
  31. extern pid_t getpid (void);
  32. extern void dl_message (char *fmt, char *arg);
  33. extern int system (const char *);
  34. extern int unlink (const char *);
  35. extern int link (const char *, const char *);
  36. extern void dl_error (char *fmt, char *arg);
  37.  
  38. int
  39. dl_linkfile(char *ofile, char *mfile, char *ifile, char *libs, long unsigned int taddr, long unsigned int daddr, int vstamp)
  40. {
  41.     char namebuf[512];
  42.     char cmdbuf[512];
  43.     int rv;
  44.  
  45.     sprintf(namebuf, "%s.%d", ofile, getpid());
  46.     sprintf(cmdbuf, "ld -o %s -x -A %s -z -T %x -D %x -VS %d %s %s",
  47.         namebuf, mfile, taddr, daddr, vstamp, ifile, libs);
  48.     dl_message("install: running linker on module %s.", ifile);
  49.     rv = system(cmdbuf);
  50.     dl_message("install: link done.", 0);
  51.     if ( rv == 0 ) {
  52.         unlink(ofile);
  53.     if ( link(namebuf, ofile) < 0 ) {
  54.         dl_error(0, ofile);
  55.         return 0;
  56.     }
  57.     unlink(namebuf);
  58.     }
  59.     return rv == 0;
  60. }
  61.